/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    My_Radio
 *    
 *    MyRadioAdapter
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2011-1-28
 *    @version: 1.0
 *
 ******************************************************************************/

package small.hero.entertaiment.radio.jiujie.version.zl.adapter;

import small.hero.entertaiment.radio.jiujie.version.zl.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * MyRadioAdapter of My_Radio.
 * 
 * @author zuochen
 * 
 */

public class MyRadioAdapter extends BaseAdapter {
	public static final int[] PIC_ID = { R.drawable.bg_dancer,
			R.drawable.bg_hiphop, R.drawable.bg_jazz, R.drawable.bg_lounge,
			R.drawable.bg_pop, R.drawable.bg_rock, R.drawable.bg_metal };
	public static final String[] NAME = { "Dance-Electro", "Hip Hop", "Jazz",
			"Lounge", "Pop", "Rock", "Metal" };
	private final Context mContext;

	public MyRadioAdapter(Context mContext) {
		this.mContext = mContext;
	}

	@Override
	public int getCount() {
		return PIC_ID.length;
	}

	@Override
	public Object getItem(int position) {
		return PIC_ID[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			final LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.purple_row_item, null);

		}
		final TextView mTextView = (TextView) convertView
				.findViewById(R.id.PurpleRowTextView);
		final ImageView mImageView = (ImageView) convertView
				.findViewById(R.id.PurpleImageView);
		mTextView.setText(NAME[position]);
		mImageView.setBackgroundResource(PIC_ID[position]);
		return convertView;
	}

}
